﻿Public Class UserControl

    Private Sub ChangePasswordButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangePasswordButton.Click
        CurrentPasswordLabel.Show()
        CurrentPasswordTextBox.Show()
        NewPasswordLabel.Show()
        NewPasswordTextBox.Show()
        DoChangePasswordButton.Show()
        ChangePasswordButton.Hide()
    End Sub

    Private Sub DoChangePasswordButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DoChangePasswordButton.Click
        If NewPasswordTextBox.Text = ConfirmPasswordTextBox.Text Then
            MPQClient.Server.ChangePassword(Username, CurrentPasswordTextBox.Text, NewPasswordTextBox.Text)
        Else
            MsgBox("Passwords do not match")
        End If
    End Sub

    Friend Sub OnPasswordChange(ByVal Success As Boolean, Optional ByVal Exception As Exception = Nothing)
        If Success = True Then
            MsgBox("Password Changed")
            ChangePasswordButton.Show()
            CurrentPasswordLabel.Hide()
            CurrentPasswordTextBox.Hide()
            NewPasswordLabel.Hide()
            NewPasswordTextBox.Hide()
            DoChangePasswordButton.Hide()
        Else
            MsgBox("Could not change password:" & vbCr & Exception.Message)
        End If
    End Sub

    Private Sub UserControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        MPQClient.Server.GetUserDetails(Username)
    End Sub

    Private Sub ChangeMultiplierButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeMultiplierButton.Click
        MPQClient.Server.SetUserMultipler(Username, InputBox("Enter new multiplier"))
        MPQClient.Server.GetUserDetails(Username)
    End Sub

    Private Sub LogOutButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LogOutButton.Click
        MainForm.DoLogOut()
    End Sub
End Class
